import 'package:flutter/material.dart';

//缩放（Scale）以及位置调整（Position)
class FittedBoxWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: new AppBar(
        title: new Text("FittedBox"),
        leading: new BackButton(),
      ),
      body: new Container(
        color: Colors.amberAccent,
        width: 300,
        height: 300,
        child: new FittedBox(
          //按照child宽高比缩放，直到填满父布局最短的一条边
          fit: BoxFit.contain,
          //按照child原尺寸
//          fit: BoxFit.none,
          //child宽高填满父布局
//          fit: BoxFit.fill,
          //按照child宽高比缩放，直到填满父布局最短一条边
//          fit: BoxFit.cover,
          //按照child宽高比缩放，直到宽填满父布局
//          fit: BoxFit.fitWidth,
          //按照child宽高比缩放，直到高填满父布局
//          fit: BoxFit.fitHeight,
          //当父布局小于子布局，子布局=》 BoxFit.contain；当父布局大于子布局，子布局=》BoxFit.none
//          fit: BoxFit.scaleDown,
          alignment: Alignment.topLeft,
          child: new Container(
            color: Colors.red,
            child: new Text('FittedBox'),
          ),
        ),
      ),
    );
  }
}
